import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

import { Meteor } from 'meteor/meteor';

class OtherDevicesCollection extends Mongo.Collection {
    update(selector, modifier) {
        const result = super.update(selector, modifier);
        return result;
    }
    insert(log, callback) {
        const ourOtherDevices = log;
        const result = super.insert(ourOtherDevices, callback);
        return result;
    }
    remove(selector, callback) {
        const result = super.remove(selector, callback);
        return result;
    }
}

export const OtherDevices = new OtherDevicesCollection('other_devices');

OtherDevices.deny({
    insert() { return true; },
    update() { return true; },
    remove() { return true; },
});

OtherDevices.schema = new SimpleSchema({

    d_id: {
        label: '设备Id',
        type: String,
        optional: true
    },
    d_name: {
        label: '设备名称',
        type: String,
        optional: true
    },
    roomId: {
        label: '所属房间ID',
        type: String
    },
    roomName: {
        label: '所属房间名称',
        type: String
    },
    c_date: {
        label: '添加时间',
        type: Date,
    },
    isDef:{
        label:'是否为默认值',
        type:Boolean,
        optional:true
    },
    channel: {
        label: '通道',
        type: [Object]
    },
    'channel.$.channelType':{
        label:'通道类型',
        type:Number
    },
    'channel.$.channelStatus':{
        label:'通道状态',
        type:String
    },
    'channel.$.controlId':{
        label:'控制设备或情景Id',
        type:String
    },
    'channel.$.controlType':{
        label:'控制类型',
        type:String
    },
    'channel.$.controlStatus':{
        label:'控制状态',
        type:String
    },
    productNumber:{
        label:'设备型号',
        type:String
    },
    devType:{
        label:'设备类型',
        type:String
    },
    gatewayId:{
        label:'网关id',
        type:String
    },
    version:{
        label:'版本',
        type:String
    }

});
OtherDevices.attachSchema(OtherDevices.schema);
